//
//  LoopProgressView.m
//  UEAssistant
//
//  Created by mac on 2017/7/19.
//  Copyright © 2017年 youyixinxi. All rights reserved.
//

#import "LoopProgressView.h"
@interface LoopProgressView ()

@property(nonatomic,strong)CAShapeLayer *backLayer;
@property(nonatomic,strong)CAShapeLayer *foreLayer;
@property(nonatomic,strong)UIBezierPath *backPath;

@property(nonatomic,strong)CAGradientLayer *gradientLayerLeft;

@end


@implementation LoopProgressView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame])
    {
        [self setUp];
        
    }
    return self;
    
}
- (void)setUp
{
        
    self.backLayer =[CAShapeLayer layer];
    self.backLayer.fillColor  =[UIColor clearColor].CGColor;
    self.backLayer.frame = self.bounds;
    self.backLayer.lineWidth = 2;
    self.backLayer.strokeColor =RGB(241, 241, 241, 1).CGColor;
    [self.layer addSublayer:self.backLayer];
    
    self.foreLayer =[CAShapeLayer layer];
    self.foreLayer.fillColor  =[UIColor clearColor].CGColor;
    self.foreLayer.frame = self.bounds;
    self.foreLayer.strokeColor =mainColor.CGColor;
    self.foreLayer.lineWidth = 2;
    [self.layer addSublayer:self.foreLayer];
    
    
    UIBezierPath *path=  [UIBezierPath bezierPathWithArcCenter:CGPointMake(self.bounds.size.width/2, self.bounds.size.height/2) radius:self.bounds.size.width/2-2 startAngle:-M_PI_2 endAngle:M_PI *1.5 clockwise:YES];
    self.backPath = path;
    
    self.backLayer.path = self.backPath.CGPath;
    self.foreLayer.path = self.backPath.CGPath;
    self.foreLayer.strokeEnd = 0;

    
}
-(void)setProgressValue:(CGFloat)progressValue
{
    _progressValue = progressValue;
    self.foreLayer.strokeEnd = progressValue;
}


@end

